/*


 */

package jas.http.response;

/**
 * Represents an HTTP response code.
 */
public enum ResponseCode {
    OK("OK",200),
    CREATED("CREATED",201),

    MOVED_PERMANENTLY("MOVED PERMANENTLY", 301),

    BAD_REQUEST("BAD REQUEST", 400),
    NOT_FOUND("NOT FOUND",404),

    INTERNAL_SERVER_ERROR("INTERNAL SERVER ERROR", 500),
    
    MALFORMED_URI("MALFORMED URI",600);

    private final String s;
    private final int code;
    
    public static ResponseCode fromNumber(int code) {
        for (ResponseCode r : values()) {
            if (r.code == code)
                return r;
        }
        return null;
    }

    private ResponseCode(String s, int code) {
        this.s = s;
        this.code = code;
    }

    public int getCodeNumber() {
        return code;
    }
    
    public String getName() {
        return s;
    }

    @Override
    public String toString() {
        return code+" "+s;
    }
}
